home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / wstype / source / werror.c < prev    next >
C/C++ Source or Header  |  1991-10-18  |  3KB  |  170 lines

  1. /***   [werror.c]
  2. *
  3. *    エラーウィンドウ        (C)ささがわ
  4. *
  5. *    For GNU C Compiler (GCC)   Version 1.39
  6. *
  7. ***/
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "graph.h"
  12. #include "mos.h"
  13. #include "window.h"
  14. #include "icn.h"
  15. #include "others.h"
  16. #include "beep.h"
  17.  
  18. #define WH_TITLE    1
  19. #define WH_ON        2
  20. #define WH_OTHER    0
  21.  
  22. extern int    PAL_Back;
  23. extern int    PAL_Black;
  24. static int    wx, wy;
  25.  
  26. static void    Draw_window(void);
  27. static int    Where(int, int);
  28. static void Message(int, const char *);
  29.  
  30. void WIND_error(int no, const char *f) {
  31.     int        ret = 0;
  32.     char    fname[20];
  33.     struct RECT    a, b;
  34.     
  35.     if (no < 0 || 5 < no)
  36.         return;
  37.     
  38.     MOS_disp(0);
  39.     ICN_mos(0);
  40.     EGB_cls(0);
  41.     MOS_disp(1);
  42.     if (f == NULL)
  43.         fname[0] = '\0';
  44.     else {
  45.         strncpy(fname, f, 20);
  46.         fname[strLE(fname, 18)] = '\0';
  47.     }
  48.     wx = 174;
  49.     wy = 169;
  50.     a.x1 = 319;    a.y1 = 259;
  51.     a.x2 = 320;    a.y2 = 260;
  52.     b.x1 = wx;    b.y1 = wy;
  53.     b.x2 = wx + 291;    b.y2 = wy + 141;
  54.     afterImage(&a, &b);
  55.     
  56.     Draw_window();
  57.     Message(no, fname);
  58.     while (!ret) {
  59.         char    mb;
  60.         int        mx, my, wh;
  61.         
  62.         CLOCK(0);
  63.         if (MOS_rdpos(&mb, &mx, &my), !(mb & 1))
  64.             continue;
  65.         
  66.         if ((wh = Where(mx, my)) == WH_ON) {
  67.             if (Button(wx + 195, wy + 108, wx + 274, wy + 129)) {
  68.                 ret = 1;
  69.             }
  70.         } else if (wh == WH_TITLE) {
  71.             struct RECT    s, w;
  72.             
  73.             w.x1 = wx;    w.y1 = wy;
  74.             w.x2 = wx + 291;    w.y2 = wy + 141;
  75.             s.x1 = 0;    s.y1 = 40;    s.x2 = 639;    s.y2 = 463;
  76.             if (dragWindow(mx, my, &w, &s, 0, 0)) {
  77.                 wx = w.x1;    wy = w.y1;
  78.                 MOS_disp(0);
  79.                 EGB_cls(0);
  80.                 MOS_disp(1);
  81.                 Draw_window();
  82.                 Message(no, fname);
  83.             }
  84.         } else {
  85.             while (MOS_rdpos(&mb, &mx, &my), mb & 1);
  86.         }
  87.     }
  88.     
  89.     MOS_disp(0);
  90.     EGB_cls(0);
  91.     MOS_disp(1);
  92.     return;
  93. }
  94.  
  95. static void Draw_window(void) {
  96.     int        i;
  97.     struct opnwin_t    opw;
  98.     
  99.     opw.title = "お 知 ら せ";
  100.     opw.x1 = wx;
  101.     opw.y1 = wy;
  102.     opw.x2 = opw.x1 + 291;
  103.     opw.y2 = opw.y1 + 141;
  104.     opw.shdw = 1;
  105.     opw.canb = 0;
  106.     opw.nopt = 0;
  107.     opw.wopt = NULL;
  108.     opw.expb = 0;
  109.     opw.ord = 0;
  110.     MOS_disp(0);
  111.     drawWindow(&opw);
  112.     
  113.     EGB_boxf(wx + 14, wy + 37, wx + 47, wy + 70, PAL_Black, 15);
  114.     ICN_put(25, wx + 15, wy + 38, PAL_Black);
  115.     DrawButton(1, wx + 194, wy + 107, wx + 275, wy + 130);
  116.     for (i = 0; i < 2; i++)
  117.         EGB_str2(" 確    認 ", wx + 195 + i, wy + 126, PAL_Black);
  118.     MOS_disp(1);
  119.     BEP_on();
  120. }
  121.  
  122. static int Where(int x, int y) {
  123.     int        ret;
  124.     
  125.     x -= wx;
  126.     y -= wy;
  127.     if (5 < x && x < 286 && 5 < y && y < 26)
  128.         ret = WH_TITLE;
  129.     else if (194 < x && x < 275 && 107 < y && y < 130)
  130.         ret = WH_ON;
  131.     else
  132.         ret = WH_OTHER;
  133.     
  134.     return ret;
  135. }
  136.  
  137. static void Message(int no, const char *f) {
  138.     int        i;
  139.     static const char *mes[][2] = { {
  140.     /*      "                           " */
  141.             "ファイルの読み込みに",
  142.             "            失敗しました"
  143.         }, {
  144.             "メモリが足りません",
  145.             ""
  146.         }, {
  147.             "これ以上、ウィンドウを",
  148.             "       開くことは出来ません"
  149.         }, {
  150.             "背景画の読み込みに",
  151.             "            失敗しました"
  152.         }, {
  153.             "サウンドの読み込みに",
  154.             "            失敗しました"
  155.         }, {
  156.             "この機能は、将来",
  157.             "     サポートされる予定です"
  158.     } };
  159.     
  160.     i = !f[0] ? 10 : 0;
  161.     MOS_disp(0);
  162.     EGB_str2(mes[no][0], wx + 62, wy + 54 + i, PAL_Black);
  163.     EGB_str2(mes[no][1], wx + 62, wy + 74 + i, PAL_Black);
  164.     if (f[0]) {
  165.         EGB_str2("ファイル名", wx + 62, wy + 94, PAL_Black);
  166.         EGB_str2(f, wx + 118, wy + 94, PAL_Black);
  167.     }
  168.     MOS_disp(1);
  169. }
  170.